<template>
  <div class="repairBox">
    <div class="container">
      <div class="breadBox">
        <el-breadcrumb separator="/">
          <el-breadcrumb-item :to="{ path: '/repairList' }">我的报事报修</el-breadcrumb-item>
          <el-breadcrumb-item>报事报修详情</el-breadcrumb-item>
        </el-breadcrumb>
      </div>
      <div class="detailBox">
        <div class="baseInfo">
          <el-row :gutter="20">
            <el-col :span="8"><div>报事报修编号：{{data.serviceBxNumber}}</div></el-col>
            <el-col :span="8"><div>服务费（元）：<span style="color: #ff4c4e">{{data.serviceFee}}</span></div></el-col>
            <el-col :span="8"><div>处理状态：{{formatStatus(data.serviceStatus) }}</div></el-col>
          </el-row>
        </div>

        <div class="moreInfoBox">
          <el-row :gutter="20">
            <el-col :span="8"><div class="moreInfoTxt">事故区域：{{formatAreaStatus(data.serviceRange) }}</div></el-col>
            <el-col :span="8"><div class="moreInfoTxt">关联房产编号：{{data.projectName}}</div></el-col>
            <el-col :span="8"><div class="moreInfoTxt">事故设备：{{data.relateDeviceTypeName}}</div></el-col>
            <el-col :span="24"><div class="moreInfoTxt">联系方式：{{data.contactPhoneNumber}}</div></el-col>
            <el-col :span="24"><div class="moreInfoTxt">内容描述：{{data.serviceDescription}}</div></el-col>
            <el-col :span="24">
              <p>图片：</p>
              <div class="imgbox">
                <el-row  :gutter="20">
                  <el-col v-for="(item,index) in data.imgs" :key="index"  :span="6"><div  @click="showDialog(item)"><img :src="item" alt=""></div></el-col>
                </el-row>
              </div>

            </el-col>
          </el-row>
        </div>
        <div class="stepBox">
          <p class="stepBoxTitle">操作记录</p>
          <div style="height: 300px;">
            <el-steps direction="vertical" :active="data.workOrderStatusNumber">
              <el-step v-for="(item,index) in data.workOrderStatusList" :key="index" :title="item.statusName" description=""><template slot="description">
                <p>{{ item.finishByName }}</p><p>{{ item.finishTime }}</p>
              </template></el-step>
            </el-steps>
          </div>
        </div>
      </div>
    </div>
    <el-dialog :visible.sync="dialogVisible" width="50%">
      <img width="100%" :src="dialogImageUrl" alt="">
    </el-dialog>
  </div>
</template>

<script>
import api from "../../../api/app";
export default {
  name: "addRepairReport",
  data() {
    return {
      dialogVisible:false,
      dialogImageUrl:'',
      id:'',
      data:{},
      areaList:[{
        dictValue: 1,
        dictName: "房内区域",
      },{
        dictValue: 2,
        dictName: "公共区域",
      }],
      //工单状态(1.待创建 2.已创建 3.已接单 4.已完成)
      statusList: [
        {
          dictValue: '1',
          dictName: "待创建",
        },
        {
          dictValue: '2',
          dictName: "已创建",
        },
        {
          dictValue: '3',
          dictName: "已接单",
        },
        {
          dictValue: '4',
          dictName: "已完成",
        },
      ],
    };
  },
  mounted() {
    this.id=this.$route.query.id
    this.getReportDetail()
  },
  methods:{
    showDialog(url){
      console.log(url)
      this.dialogImageUrl=url
      this.dialogVisible=true
    },
    getReportDetail(){
      api.getRepairDetail(this.id).then(res=>{
        console.log(res)
        this.data=res.data.data
      }).catch(err=>{
        console.log(err)
      })
    },
    formatStatus(cellValue) {
      let _types = this.statusList || [];
      let _obj =
          _types.find((value, index) => {
            console.log(index)
            return value.dictValue === cellValue;
          }) || {};
      return _obj.dictName || "";
    },
    formatAreaStatus(cellValue) {
      let _types = this.areaList || [];
      let _obj =
          _types.find((value, index) => {
            console.log(index)
            return value.dictValue === cellValue;
          }) || {};
      return _obj.dictName || "";
    },
  }
}
</script>

<style scoped>
.container{
  width: 800px;
  margin: 0 auto;
  min-height: 700px;
}
.breadBox{
  margin-top: 40px;
}
.detailBox {
  margin-top: 20px;
  padding: 20px;
}
.imgbox{
  margin-top: 10px;
}
.imgbox img{
  width: 100%;
  height: 150px;
  object-fit: contain;
}
.baseInfo {
  font-size: 16px;
  color: #282828;
  font-weight: bold;
  padding: 20px 10px;
  border-radius: 8px;
  box-shadow: 0 0 10px #ddd;
}
.moreInfoBox {
  padding: 20px 10px;
  margin-top: 20px;
  color: #656565;
  font-size: 14px;
  border-radius: 8px;
  border-radius: 8px;
  box-shadow: 0 0 10px #ddd;
}
.moreInfoTxt {
  margin-bottom: 20px;
}

.stepBox {
  margin-top: 20px;
  padding: 20px 10px;
  border-radius: 8px;
  box-shadow: 0 0 10px #ddd;
}
p.stepBoxTitle {
  font-size: 16px;
  color: #282828;
  font-weight: bold;
  padding-bottom: 5px;
  border-bottom: 1px solid #3a8ee6;
  margin-bottom: 20px;
}
</style>